<template>
	<view class="mainpadding2" style="padding-bottom: 150rpx;">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;"></view>
		</view>
		<view class="xiahuaxian margin_top" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="shilitu margin_right2">
					<image :src="item.kc.image_text" mode=""></image>
				</view>
				<view class="flexcolumn"
					style="width: 69%;align-items: flex-start;height: 160rpx;justify-content: space-between;">
					<view class="titletext xiaohei fonweight yhxk">{{item.kc.name}}</view>
					<view class="flexleft">
						<view class="sanshier xiaohong fonweight">￥{{item.kc.price}}</view>
					</view>
				</view>
			</view>
			<view class="ershiba xiaohui margin_top2">请假原因：{{item.qjyy}}</view>
			<view class="ershiba xiaohui margin_top2">请假人：{{item.user.username}}</view>
			<view class="ershiba xiaohui margin_top2">教练：{{item.kckcb.jlinfo.name}}</view>
			<view class="ershiba xiaohui margin_top2">上课时间：{{item.sk_time_text}} {{item.kckcb.start_time}}至{{item.sk_time_text}} {{item.kckcb.end_time}}</view>
			<view class="ershiba xiaohui margin_top2">审核状态：
			<text class="xiaolv" v-if="item.status==7">请假通过</text>
			<text class="xiaohuang" v-if="item.status==6">待审核</text>
			</view>
			<view class="flexright margin_top2" v-if="item.status==6">
				<view class="lvbtn" @click="show=true;currentid=item.id">审核</view>
			</view>
		</view>
		<u-modal :show="show" title="审批" confirmText="确认" @confirm="shenhe" cancelText="取消" @cancel="show=false"
			showCancelButton>
			<view class="slot-content" style="width: 600rpx;">
				<view class="flexbetween margin_top">
					<view class="main_size bold hei_text">审批：</view>
					<view class="flexright">
						<u-radio-group v-model="status" placement="row" circle>
							<u-radio activeColor="#1ba95b" label="请假通过" :customStyle="{marginRight: '30rpx'}"
								name="7"></u-radio>
							<u-radio activeColor="#1ba95b" label="拒绝" name="1"></u-radio>
						</u-radio-group>
					</view>

				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				show: false,
				currentid: "",
				user_zbfapply_listid: "",
				status:"7"
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid = options.user_zbfapply_listid
		},
		onShow() {
			this.init()
		},
		methods: {
			shenhe() {
				httpRequest.request("/api/user/kckcbUserQjCl", 'GET', {
					id: this.currentid,
					status: this.status
				}).then(res => {
					this.show=false
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id: this.user_zbfapply_listid
				}
				let url = '/api/user/kckcbUserQjIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.shilitu {
		width: 200rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>